package com.trkj.servlet;


import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.trkj.dao.MemberDAO;
import com.trkj.dao.MemberDAOFactory;

/**
 * Servlet implementation class EditMemberServlet
 */
@WebServlet("/edit_member")
public class EditMemberServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private MemberDAO memberDAO = MemberDAOFactory.createDAO();

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		
		int mid = Integer.parseInt(request.getParameter("mid"));
		String curpage = request.getParameter("curpage");
		
		String realName = request.getParameter("real_name");
		String sex = request.getParameter("sex");
		String phone = request.getParameter("phone");
		String birthday = request.getParameter("birthday");
		
		memberDAO.edit(mid, realName, 
				sex, phone, 
				java.sql.Date.valueOf(birthday));
		response.sendRedirect("member_list?curpage=" + curpage +"&pagesize=2&");
	}

}